#!/usr/bin/env python3
# -*- coding: utf-8 -*-
form collections import Iterable
#切片
L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack']
#从索引0开始取，直到索引3为止，但是不包括索引3
print(L[0:3])
print(L[:5:2])#前5个数，每2个取一个
print((0, 1, 2, 3, 4, 5)[:3])
print('ABCDEFG'[:3])
#====================================

#迭代
d = {'a':1,'b':2,'c':3}
for key in d:
	print(key)

for value in d.values():
	print(value)

for k,v in d.items():
	print(k.',',v)
for ch in 'abc':
	print(ch)
for x, y in [(1, 1), (2, 4), (3, 9)]:
	print(x, y)

#判断对象是否可迭代
 isinstance('abc', Iterable)

#把一个list变成索引-元素对
for i, value in enumerate(['A', 'B', 'C']):
	print(i,value)
